package com.demo.print;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
import java.util.Locale;

public class TestLocalDateTimeFormatter {
    public static void main(String[] args) {
        DateTimeFormatter italianFormatter =
                DateTimeFormatter.ofPattern("d, MMMM yyyy", Locale.ITALIAN);
        LocalDate date1 = LocalDate.now();
        String formattedDate = date1.format(italianFormatter);
        System.out.println(formattedDate);
        LocalDate date2 = LocalDate.parse(formattedDate, italianFormatter);
        System.out.println(date2);

        DateTimeFormatter italianFormatter1 = new DateTimeFormatterBuilder()
                .appendText(ChronoField.DAY_OF_MONTH)
                .appendLiteral(". ")
                .appendText(ChronoField.MONTH_OF_YEAR)
                .appendLiteral(" ")
                .appendText(ChronoField.YEAR)
                .parseCaseInsensitive()
                .toFormatter(Locale.ITALIAN);
    }
}
